package com.kejiguan.ui.dialog;

import android.content.Context;

import com.kejiguan.ui.R;
import com.kejiguan.ui.model.MenuItem;

import java.util.List;

/**
 * Created by YYY on 2016/4/30.
 */
public class AddUserDialogUtil {

    private static AddUserDialogUtil instance;
    private AddUserDialog addUserDialog;

    public AddUserDialogUtil() {
    }

    public static AddUserDialogUtil getInstance() {
        if (instance == null) {
            synchronized (AddUserDialogUtil.class) {
                if (instance == null) {
                    instance = new AddUserDialogUtil();
                }
            }
        }
        return instance;
    }

    public void show(Context context,List<MenuItem> menuItems,AddUserDialog.OnNewUserAddListener onNewUserAddListener)
    {
        if (null==addUserDialog||!addUserDialog.isShowing())
        {
            addUserDialog=new AddUserDialog(context, R.style.dialog_tran);
        }

        addUserDialog.withMenus(menuItems).withOnNewUserAddListener(onNewUserAddListener).show();
        addUserDialog.setCanceledOnTouchOutside(true);
    }


    public void dismiss()
    {
        if (null!=addUserDialog&&addUserDialog.isShowing())
        {
            addUserDialog.dismiss();
        }
    }
}
